-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add TVM deploy #1326
base: master
Are you sure you want to change the base?
Add TVM deploy #1326
Conversation
Job PR-1326-1 is done. |
This is a demo application which illustrates how to use pretrained GluonCV models in c++ environments with the support of TVM. | ||
|
||
## Build instruction | ||
Always use `git clone --recursive`, if not, we can update tvm submodule `git submodule update --recursive --init`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unlike a separate project, adding tvm into gluoncv as a submodule is an overkill.
Let's remove the submodule of tvm and add one setence to ask user to git clone the tvm module
Please clone the full TVM repository by `git clone --recursive https://github.com/apache/incubator-tvm.git`
@@ -0,0 +1,275 @@ | |||
"""Helper utils for export HybridBlock to symbols.""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
export.py, export_classify.py, export_detection.py are duplicates?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just suggestions:)
.gitmodules
Outdated
@@ -0,0 +1 @@ | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
empty line
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks
@@ -0,0 +1,4 @@ | |||
build/* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove .git
files under this dir
|
||
TVMArrayCopyFromBytes(input,image.data(),224*224*3*4); | ||
|
||
tvm::runtime::PackedFunc set_input = mod.GetFunction("set_input"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can use zero_copy
?
else: | ||
data_shape = (3, 512, 605) | ||
model = gcv.model_zoo.get_model(args.model, pretrained=True) | ||
export_tvm("model", model, data_shape, ctx=mx.cpu(), preprocess=TvmPreprocess(), target='llvm -mcpu=core-avx2', use_autotvm=False) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we add args for ctx and target?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, those variables can be set as arguments and assigned values according to specific environment. I just provide a demo for deployment using TVM, so feel free to make changes when needed.
Job PR-1326-3 is done. |
Just curious, I saw two "clipp.hpp" files, is it possible to reuse it instead of putting it in two folders? Thank you. |
@liueo See other reviewer's comments, please try to reduce duplicate code |
Job PR-1326-4 is done. |
@liueo Can you address the comments? We could merge this once done ASAP |
INCLUDE_DIRECTORIES(${HOME_TVM}/3rdparty/dmlc-core/include) | ||
INCLUDE_DIRECTORIES(${HOME_TVM}/3rdparty/dlpack/include) | ||
|
||
set(PNG_LIBS libpng.a) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't find libpng, libz, libjpeg anywhere in the PR so this much be something hardcoded.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we want to build libjpeg, libpng statically and link to them, these libraries should be prepared before building the full project. I didn't provide these files because they depend on specific operating system. I write some comments about the procedure in README and thought developers would build these libraries according to their target platform. Could you please give me some suggestions on how to make changes? Thanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The ideal way is to provide the build system for libjpeg and libpng in a cross-platform way(cmake).
We can include the source of libpng/jpeg in this case. Build for static linking, and finally include them in this demo probject CMakeList.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this is using CMake, Why not use find_package()
for these?
Job PR-1326-8 is done. |
Job PR-1326-9 is done. |
Job PR-1326-10 is done. |
Job PR-1326-11 is done. |
Job PR-1326-12 is done. |
Job PR-1326-13 is done. |
Job PR-1326-14 is done. |
Job PR-1326-15 is done. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Provide a demo for using pretrained GluonCV models in C++ environments with the support of TVM.